function initMessage() {
    setTimeout(async () => {
        window.zwttools = {};
        window.spopoup = window.wCreatePopup('http://localhost:5000/nested/index.html')


        setTimeout(() => {
            window.spopoup.postMessage({
                type: 'js',
                quote: {
                    symbol: 'pixiv'
                },
                config: {
                    jsname: 'pixiv'
                }
            });
        }, 10000);
    }, 6000);

    window.addEventListener('message', async (e) => {
        if (e.origin === 'http://localhost:5000') {
            if (e.data && e.data.type === 'js') {
                let js = e.data.js;
                // let trans = fromBinary(data)
                // let trans = decodeURIComponent(window.atob(data));
                let m = await window.loadJsRes(js);

                m.init();
                window.sendNotify(`installed ${m?.ver} `);
                // alert(m)
                // console.dir(m)
                window.zwttools = m;

                // openWatchMode()
            }
            if (e.data && e.data.type === 'run') {
                let [method = '', args = []] = e.data.args;
                if (method && window[method]) {
                    let res = window[method].apply(window, args);
                    e.source.postMessage({
                        res
                    }, e.origin)
                }
            }
        }
    });
}
globalThis.initMessage = initMessage;